<template>
    <section>




        <!--新增界面-->
        <el-col :sm="24" :lg="16">
            <div class="grid-content bg-purple">
                <div class="dev-title">新建工单</div>
            </div>
            <div class="col-bg clearfix">
                <el-form :model="addForm" label-width="100px" :rules="addFormRules" ref="addForm">
                    <el-form-item label="标题" prop="title">
                        <el-input v-model="addForm.title" style="width:200px;"></el-input>
                    </el-form-item>

           
                    <el-form-item label="内容" prop="content">
                            <el-input type="textarea" v-model="addForm.content"></el-input>
                        </el-form-item>
                    <el-form-item label="联系方式" prop="contacts">

                        <el-input v-model="addForm.contacts" style="width:400px;"></el-input>
                    </el-form-item>
                    <el-form-item label="分类">
                        <el-radio-group v-model="addForm.type">
                            <el-radio label="1">问题</el-radio>
                            <el-radio label="2">建议</el-radio>
                        </el-radio-group>
                    </el-form-item>
                   
                </el-form>
                <div slot="footer" class="dialog-footer" style="text-align: center;">
                    <el-button @click.native="addFormVisible = false">取消</el-button>
                    <el-button type="primary" @click.native="addSubmit" :loading="addLoading">提交</el-button>
                </div>
            </div>
        </el-col>
    </section>
</template>

<script>
    import {
        suggest_post,
        conversation_post
    } from '../../api/api';

    export default {
        data() {


            return {
                addLoading: false,
                addFormRules: {
                    title: [{
                        required: true,
                        message: '请输入标题',
                        trigger: 'blur'
                    }],
                    contacts: [{
                        required: true,
                        message: '请输入联系方式',
                        trigger: 'blur'
                    }],
                    content: [{
                        required: true,
                        message: '请输入内容',
                        trigger: 'blur'
                    },
                 { min: 1, max: 100, message: '内容长度不能超过100个字', trigger: 'blur' }],

                },
                //新增界面数据
                // addForm: {
                //     name: '',
                //     contactType: '1',
                //     contactValue: '',
                //     type: '1',
                //     content: ''
                // }
                addForm: {
                    title: '',
                    contacts: '',
                    content: '',
                    type:'1'
                }

            }
        },
        methods: {


            addSubmit: function () {
                this.$refs.addForm.validate((valid) => {
                    if (valid) {
                        this.$confirm('确认提交吗？', '提示', {}).then(() => {

                            this.addLoading = true;
                            //NProgress.start();
                            let para = Object.assign({}, this.addForm);

                            conversation_post(para).then((res) => {
                                 this.begCode(res.code,res.message);
                                    this.addLoading = false;
                                if (res.code == 0) {
                                    //NProgress.done();
                                    this.$message({
                                        message: '提交成功',
                                        type: 'success'
                                    });
                                    this.$refs['addForm'].resetFields();
                                    this.addFormVisible = false;

                                }

                            });
                        });
                    }
                });
            }


        },
        mounted() {

            let para = {
                pageNo: 1,
                pageSize: 1000
            };



        }
    }
</script>

<style scoped>
   
</style>